

# 将标签图从json文件中批量取出
import os
import shutil

path = r'E:/dataset/new_car/'
dirpath = r'/dataset/new_car/labels/'

# with open('get_unet_pic.txt','r') as file1:
#     contents = file1.read()
#     print(contents)
#     print(111)

# with open('get_unet_pic.txt','r') as lines:
#     for line in lines
#         print(line)

file2 = 'get_unet_pic.txt'

path = r'E:/dataset/new_car/'
dirpath = r'/dataset/new_car/labels/'

with open(file2) as lines:
    for line in lines:
        # print(line.strip())
        pic_name=line.strip()
        pic_path=os.path.join(path,pic_name)
        pic_dir_path=os.path.join(dirpath,pic_name)

        print(pic_path)
        print(pic_dir_path)

        shutil.copy(pic_path,pic_dir_path)

        # print("\n" + line.strip())
        #strip()是用于去除字符串里面的空格.这个可以上网查一下相关的资料.


# for eachfile in os.listdir(path):
#     if os.path.isdir(path + eachfile):
#         if os.path.exists(path + eachfile + '/label.png'):
#             shutil.copy(path + eachfile + '/label.png', dirpath + eachfile.split('_')[0] + '.png')
#             print(eachfile + ' successfully moved')

# with open(file2) as file_work:
#     line3 = file_work.readlines()

# #上面的line3是一个列表

# for line in line3:
#     print(line)


# dst_file = './test_copy2'
# src_file = './test_copy1'
# current_list = glob.glob(os.path.join(src_file,'*'))
 
# for x in current_list:
#     shutil.copy(x,dst_file)




# shutil.copyfile(os.getcwd()+'/Map123.gif',os.getcwd()+'/ceshi.gif')



